try {
<% if params[:from_field] && successful? %>
  <%= render 'update_field_on_create' %>
<% else %>
  var action_link;
  <%
    form_selector ||= element_form_id(action: :create)
    insert_at ||= :top
    always_show_create ||= active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
  -%>
  <% if always_show_create -%>
    <%= render 'update_messages' %>
  <% else -%>
    action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
    if (action_link) action_link.update_flash_messages('<%= escape_javascript(render('messages')) %>');
  <% end -%>
  <% if successful? -%>
    <%= render 'new_record', insert_at: insert_at %>
    <%= render 'refresh_create_form', always_show_create: always_show_create, form_selector: form_selector unless render_parent? %>
  <% else %>
    ActiveScaffold.replace('<%= form_selector %>','<%= escape_javascript(render('create_form', xhr: true)) %>');
    ActiveScaffold.scroll_to('<%= form_selector %>', true);
  <% end %>
<% end %>
} catch (e) { alert('RJS error:\n\n' + e.toString());}
